package utility


func CopyArr(arr []int) []int {
	ans := make([]int, len(arr))
	for i:=0; i<len(arr); i++ {
		ans[i] = arr[i]
	}
	return ans
}

func ArrArrEqual(arr1, arr2 [][]int) bool {
	if len(arr1) != len(arr2) {
		return false
	}
	for i:=0; i<len(arr1); i++ {
		if !ArrEqual(arr1[i], arr2[i]) {
			return false
		}
	}
	return true
}

func ArrSetEqual(arr1, arr2 [][]int) bool {
	if len(arr1) != len(arr2) {
		return false
	}
	for i:=0; i<len(arr1); i++ {
		if !SetEqual(arr1[i], arr2[i]) {
			return false
		}
	}
	return true
}

func SetEqual(set1, set2 []int) bool {
	arr1Set := make(map[int]struct{})
	arr2Set := make(map[int]struct{})
	for i:=0; i<len(set1); i++ {
		arr1Set[set1[i]] = struct{}{}
	}
	for i:=0; i<len(set2); i++ {
		arr2Set[set2[i]] = struct{}{}
	}
	if len(arr1Set) != len(arr2Set) {
		return false
	}
	for k, _ := range arr1Set {
		if _, ok := arr2Set[k]; !ok {
			return false
		}
	}
	return true
}

func ArrEqual(arr1, arr2 []int) bool {
	if arr1 == nil && arr2 == nil {
		return true
	}
	if (arr1 == nil && arr2 != nil) ||
		(arr1 != nil && arr2 == nil) {
		return false
	}
	if len(arr1) != len(arr2) {
		return false
	}
	for i, v := range arr1 {
		if arr2 != nil && arr2[i] != v {
			return false
		}
	}
	return true
}